/**
 * ui 组件工厂，所有需要用到的组件可在此注册
 * ant-design-vue 组件库组件注册
 * 自定义组件注册
 */

import {
    BackTop,
    PageHeader,
    Anchor,
    Button,
    ConfigProvider,
    Layout,
    Menu,
    Input,
    Space,
    Dropdown,
    Divider,
    Form,
    AutoComplete,
    Modal,
    Tree,
    Drawer,
    Row,
    Col,
    Select,
    DatePicker,
    Tooltip,
    Breadcrumb,
    Popconfirm,
    InputNumber,
    Table,
    Pagination,
    Progress,
    Tabs,
    Radio,
    Checkbox,
    Tag,
    Cascader,
    Upload,
    Popover,
    Spin,
    Alert,
    Empty,
    Steps,
} from 'ant-design-vue';

const components = [
    BackTop,
    Alert,
    Spin,
    PageHeader,
    Anchor,
    Checkbox,
    Radio,
    Button,
    ConfigProvider,
    Layout,
    Menu,
    Input,
    Space,
    Dropdown,
    Divider,
    Form,
    AutoComplete,
    Modal,
    Tree,
    Drawer,
    Row,
    Col,
    Select,
    DatePicker,
    Tooltip,
    Breadcrumb,
    Popconfirm,
    InputNumber,
    Table,
    Pagination,
    Progress,
    Tabs,
    Radio,
    Tag,
    Cascader,
    Upload,
    Popover,
    Empty,
    Steps,
];

/**
 * 自主开发的组件
 */
const personalComponents = [];

/**
 * 自主开发的插件
 */
const personalPlugins = [];

export default {
    /**
     * 注册按需引入使用到的组件
     * @param {Object} vue的createApp 实例
     */
    register(app) {
        // 设置语言
        // use(zhcn);

        // 组件库注册
        components.forEach(component => {
            app.use(component);
        });
        import('@/assets/styles/common.scss');
        // 自定义注件
        // app.component('img-cropper', withRequestConfig(ImgCropper));
        // personalComponents.forEach(component => {
        //     app.component(component.name, component)
        // });
        // personalPlugins.forEach(plugin => {
        //     app.use(plugin)
        // });

        // 注册directive
        // for (let key in directives) {
        //     app.directive(key, (el, binding)=>{
        //         directives[key](el, binding);
        //     })
        // }
        return app;
    },
};
